<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>品牌特卖</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/4.0.6/css/swiper.min.css">
    <style media="screen">
        #app {
            width: 100%;
            overflow: hidden;
            background: linear-gradient(266deg, #7D0DFC, #D116FD);
        }

        header {
            width: 100%;
            height: 44px;
        }

        .title {
            width: 100%;
            padding: 0 140px;
            text-align: center;
            white-space: nowrap;
            line-height: 44px;
            overflow: hidden;
            text-overflow: ellipsis;
            z-index: 2;
            color: #fff;
            font-size: 17px;
        }

        .title img {
            display: inline-block;
            width: 23px;
            height: 19px;
            margin-top: 12.5px;
        }

        header span {
            display: block;
            width: 44px;
            height: 44px;
            background: url(../../image/white_back.png) no-repeat;
            background-size: 22px 22px;
            background-position: center;
            position: absolute;
        }

        .index_bg {
            width: 100%;
            height: 100px;
            position: relative;
            z-index: 0;
            overflow: hidden;
        }

        .index_bg::after {
            content: '';
            width: 120%;
            height: 100px;
            position: absolute;
            left: -10%;
            top: 0;
            border-radius: 0 0 50% 50%;
            background: linear-gradient(266deg, #7D0DFC, #D116FD);
        }

        .nav {
            width: 100%;
            padding: 0 15px;
            margin-top: 15px;
            display: flex;
            justify-content: space-between;
            position: relative;
            box-sizing: border-box;
            overflow: hidden;
        }

        .nav .nav-menu {
            width: auto;
            font-size: 14px;
            color: #FFFFFF;
            letter-spacing: 0;
            /*text-align: center;*/
            /*padding-right: 22.5px;*/
            /* padding-top: 10px; */
        }

        .nav .nav-menu span {
            /*width: auto;*/
            display: block;
        }

        .nav .nav-menu span:first-child {
            /*width: 60px;*/
            height: 17px;
            line-height: 17px;
            /*border: 1px solid yellow;*/
        }

        .nav .nav-menu span.selected {
            font-size: 16px;
            height: 17px;
            font-weight: bold;
            line-height: 17px;
        }

        .nav .nav-menu span.selected_line {
            width: 20px;
            height: 1px;
            background: #fff;
            margin: 0 auto;
            margin-top: 2px;
            border-radius: 2.5px;
        }

        .swiper-slide {
            width: auto!important;
            position: relative;
        }
        .swiper-slide>span{
          display: block;
          color: #fff;
        }
        .swiper-slide span:first-child{
          height: 30px;
          /*padding: 0 5px;*/
          line-height: 30px;
          font-family: "微软雅黑";
          color: #fff;
          font-size: 15px;
        }
        .swiper-slide span.line{
          width: 50%;
          height: 2px;
          background-color: #fff;
          position: absolute;
          bottom: 0px;
          left: 50%;
          margin-left: -25%;
          border-radius: 1px;
        }

        .topmenu {
            height:30px;
            background: linear-gradient(266deg, #7D0DFC, #D116FD);
            padding: 0 5px;
            line-height: 30px;
            font-family: "微软雅黑";
            margin-bottom: 5px;
        }
        [v-cloak] {
            display: none!important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <header id="header">
            <span tapmode @click="closeWin()"></span>
            <div class="title">品牌特卖</div>
        </header>
        <!-- <div class="nav">
            <div class="nav-menu" v-for='(item,index) in navlist'>
                <span :class="{'selected':isActive==index}" tapmode @click="change(index)">{{item}}</span>
                <span :class="{'selected_line':isActive==index}"></span>
            </div>
        </div> -->
        <div class="topmenu">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div class="swiper-slide" v-for='(item,index) in navlist' tapmode @click="change(index,item.cid)">
                        <span class="text">{{item.cname}}</span>
                        <span :class="{'line':isActive==index}"></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> -->
<script src="../../script/swiper.js"></script>
<script type="text/javascript">
    apiready = function() {

        // setTimeout(function(){
        //   alert(vm.fcid)
        //
        // },10)
        vm.getcate();

    }
    var vm = new Vue({
        el: '#app',
        data: {
            isActive: 0,
            fcid:'',
            navlist: []
        },
        methods: {
            getcate: function() {
                api.ajax({
                    url: cl.apiServer + 'category/getCategoryList',
                    method: 'post',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8',
                        token:cl.userToken
                    },
                    data: {
                        body: {
                            parentId: 0,
                            ctype: 5,
                            version:cl.deviceInfo().appVersion,
                            mobileInfo:cl.systemType()
                        }
                    }
                }, function(ret, err) {
                    // alert(JSON.stringify(ret));
                    if (ret) {
                        if (ret.code == 0) {
                           vm.navlist=ret.data;
                           vm.fcid = ret.data[0].cid;
                           var header = $api.byId('app');
                           var headerH = $api.fixStatusBar(header);

                           api.openFrame({
                               name: 'brand_sale_frame',
                               url: './brand_sale_frame.html',
                               rect: {
                                   marginTop: headerH,
                                   marginBottom: api.safeArea.bottom, // main页面距离win底部的高度
                                   w: 'auto'
                               },
                               bounces: true,
                               bgColor: '#FAF9F9',
                               vScrollBarEnabled: true,
                               hScrollBarEnabled: true,
                               pageParam:{
                                 id:vm.fcid
                               }
                           });
                           setTimeout(function(){
                             var swiper = new Swiper('.swiper-container', {
                                 spaceBetween: 20,
                                 slidesPerView: 'auto',
                                 freeMode: true
                             },10);
                           });
                        }
                    }
                });
            },
            change: function(index,id) {
                vm.isActive = index;
                var jsfun1 = 'vm.clearData()';
                api.execScript({
                    frameName: 'brand_sale_frame',
                    script: jsfun1
                });
                var jsfun = 'vm.init("' + id + '");';
                api.execScript({
                    frameName: 'brand_sale_frame',
                    script: jsfun
                });

            },
            closeWin: function() {
                cl.closeWin({
                    name: 'brand_sale'
                })
            }
        }
    });
</script>

</html>
